--
-- Author: yawei.zhu
-- Date: 2018-12-14 11:49:07
--
-- MainBranchTaskView
--

local fileName = string.getModeName(...)
local ClassRef = class(fileName, app.mvc.ViewBase)

ClassRef.VIEW_ROOT_RES = Res.TaskMainBranchNode

function ClassRef:init()

	self._ui.btn_1:addClickEventListener(function()
		executeFunc(self._onOperate, "confimSelectBranchTask", {curTaskId = self._curTaskId, nextTaskId = self._nextTasks[1], desc = L(self._branchConf.useString3), img = string.format(Res.branchTaskIconPath, self._branchConf.icon3)})
    end)

	self._ui.btn_2:addClickEventListener(function()
		executeFunc(self._onOperate, "confimSelectBranchTask", {curTaskId = self._curTaskId, nextTaskId = self._nextTasks[2], desc = L(self._branchConf.useString4), img = string.format(Res.branchTaskIconPath, self._branchConf.icon4)})
	end)

	self._ui.btn_esc:addClickEventListener(function()
		self:closeView()
	end)
end

function ClassRef:updateView(data)
	if not data then return end

	self._nextTasks = data.nextTasks
	self._curTaskId = data.taskId
	self._branchConf = GD:queryMainBranchTaskConf(data.taskId)

	self._ui.tlt_name:setString(L(self._branchConf.title))
	self._ui.text_1:setString(L(self._branchConf.useString1))
	self._ui.text_2:setString(L(self._branchConf.useString2))
	self._ui.img_1:loadTexture(string.format(Res.branchTaskIconPath, self._branchConf.icon1))
	self._ui.img_2:loadTexture(string.format(Res.branchTaskIconPath, self._branchConf.icon2))
end

return ClassRef
